package main

import (
	"fmt"
	"crypto/sha256"
)

func main() {
	var a [3]int             // array of 3 integers
	fmt.Println(a[0])        // print the first element
	fmt.Println(a[len(a)-1]) // print the last element, a[2]

	// Print the indices and elements.
	for i, v := range a {
		fmt.Printf("%d %d\n", i, v)
	}

	r := [...]int{99: -1}
	// Print the elements only.
	for _, v := range r {
		fmt.Printf("%d\n", v)
	}

	c1 := sha256.Sum256([]byte("x"))
	c2 := sha256.Sum256([]byte("X"))
	fmt.Printf("%x\n%x\n%t\n%T\n", c1, c2, c1 == c2, c1)

	var z [32]byte
	zero(&z)

	for _, v := range z {
		fmt.Printf("%d\n", v)
	}

	//array := [...]int{10, 20, 30, 40, 50}
	array := [5]*int{0: new(int), 1: new(int)}
	*array[0] = 65
	fmt.Println(array)

	var array1 [3]*string

	array2 := [3]*string{new(string), new(string), new(string)}

	*array2[0] = "Red"
	*array2[1] = "Blue"
	*array2[2] = "Green"

	array1 = array2

	fmt.Println(array1, array2)

	slice := []int{10, 20, 30, 40, 50}
	newSlice := slice[1:3]

	newSlice = append(newSlice, 60)
	newSlice2 := append(slice, 70, 80)
	newSlice[1] = 35
	fmt.Println(slice,newSlice,newSlice2)

	for index, value := range slice {
		fmt.Printf("Value: %d Value-Addr: %X ElemAddr: %X\n",
			value, &value, &slice[index])
	}

	colors := map[string]string{
		"AliceBlue": "#f0f8ff",
		"Coral": "#ff7F50",
		"DarkGray": "#a9a9a9",
		"ForestGreen": "#228b22",
	}
	delete(colors, "Coral")
	for key, value := range colors {
		fmt.Printf("Key: %s Value: %s\n", key, value)
	}

}

func zero(ptr *[32]byte) {
	*ptr = [32]byte{}
}
